import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:search_people/utils/key_val_model.dart';
import 'package:search_people/value/topcolors.dart';

class HotSearchCell extends StatelessWidget {
  const HotSearchCell({
    Key? key,
    required this.md,
    this.onTap,
  }) : super(key: key);
  final KeyValModel md;
  final Function()? onTap;
  Color getIdenColor() {
    switch (md.idx) {
      case 0:
        return const Color(0xffd53814);
      case 1:
        return const Color(0xffeb7c2b);
      case 2:
        return const Color(0xffeba52b);
      default:
        return Colors.white;
    }
  }

  @override
  Widget build(BuildContext context) {
    var idx = md.idx!;
    return Container(
      height: 44.r,
      padding: EdgeInsets.symmetric(horizontal: 12.r),
      color: Colors.white,
      child: Row(
        children: [
          Container(
            width: 17.r,
            height: 17.r,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              color: getIdenColor(),
              borderRadius: BorderRadius.circular(2.r),
            ),
            child: Text(
              '${idx + 1}',
              style: TextStyle(
                  color: idx < 3 ? Colors.white : const Color(0xffcdcdcd),
                  fontSize: 13.sp),
            ),
          ),
          SizedBox(
            width: 10.r,
          ),
          Expanded(
              child: Text(
            md.key,
            style: TextStyle(color: TopColors.black_33, fontSize: 14.sp),
          )),
          Text(
            md.detail ?? '',
            style: TextStyle(
              color: const Color(0xffcdcdcd),
              fontSize: 12.sp,
            ),
          )
        ],
      ),
    );
  }
}

class HotSearchTitleWidget extends StatelessWidget {
  const HotSearchTitleWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 40.r,
      padding: EdgeInsets.symmetric(horizontal: 12.r),
      decoration: const BoxDecoration(
        gradient: LinearGradient(
          colors: [
            Color(0xffFFEBCD),
            Colors.white,
          ],
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
        ),
      ),
      child: Row(
        children: [
          Container(
            child: Image.asset(
              'assets/images/search/icon_hot.png',
              width: 14.r,
              height: 14.r,
            ),
            margin: EdgeInsets.only(right: 10),
          ),
          Text(
            '热搜人物',
            style: TextStyle(color: Color(0xff9D7047), fontSize: 15.sp),
          )
        ],
      ),
    );
  }
}
